When dealing with C, intrinsic types are in lowercase. Defined types are in all caps by convention. C data types are case-sensitive. Integer-class types can take a modifier of "signed" or "unsigned", and are signed by default.
C arrays are defined by the number of elements and are indexed from zero:
"char foo[32]" translates to DIM foo(0 TO 31) AS BYTE, or DIM foo AS STRING * 32, depending on the context of the code.
C arrays are stored in row-major order whereas PowerBASIC arrays are stored in column-major order. Bear in mind that when accessing C arrays the following C code:
k = arr[i,j]
would translate to PowerBASIC as:
k = arr(j,i)
C arrays are accessed as follows:
(0,0), (0,1), (0,2), ...
(1,0), (1,1), (1,2), ...
whereas PowerBASIC arrays are accessed:
(0,0), (1,0), (2,0), ...
(0,1), (1,1), (2,1), ...
Commonly, C/C++ code prefixes data types with "LP" which indicates a pointer. Therefore, items with the LP prefix usually correspond to a pointer in PowerBASIC; however, the size of the pointer's target will depend on the data type.
More information on C/C++ syntax can be found on the Internet, such as at http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1124.pdf and http://www.open-std.org/JTC1/SC22/WG21/
C/C++ Data Types
Type |
Language |
Format |
PowerBASIC |
C++ |
unsigned 8-bit |
BYTE (2) |
|
C/C++ |
signed 8-bit |
BYTE (2) |
|
C/C++ |
char pointer |
STRINGZ (1) |
|
double |
C/C++ |
8-byte float |
|
float |
C/C++ |
4-byte float |
|
C/C++ |
signed 32-bit |
LONG (3) |
|
long |
C/C++ |
signed 32-bit |
LONG |
short |
C/C++ |
signed 16-bit |
|
void |
C/C++ |
(no return value) |
|
(ANY) [PTR] (1) |
Defined types (SDK types)
Type |
Format |
PowerBASIC |
ATOM |
unsigned 16-bit |
|
BOOL |
signed 32-bit |
LONG |
boolean |
8-bit integer |
BYTE |
Boolean |
signed 16-bit |
INTEGER |
BOOLEAN |
8-bit integer |
BYTE |
BSTR |
dynamic string |
WSTRING {unicode} |
BYTE |
unsigned 8-bit |
BYTE |
COLORREF |
unsigned 32-bit |
|
DWORD |
unsigned 32-bit |
DWORD |
HANDLE |
unsigned 32-bit |
DWORD |
HWND/HDC/ |
unsigned 32-bit |
DWORD |
INT32 |
signed 32-bit |
LONG |
INT64 |
signed 64-bit |
|
LARGE_INTEGER |
signed 64-bit |
QUAD |
LPARAM |
signed 32-bit |
LONG |
(ANY) [PTR] (4) |
||
STRINGZ pointer |
STRINGZ [PTR] |
|
DWORD pointer |
DWORD [PTR] |
|
LONG pointer |
LONG [PTR] |
|
STRINGZ pointer |
STRINGZ [PTR] |
|
DWORD pointer |
DWORD [PTR] |
|
(ANY) [PTR] |
||
WSTRINGZ pointer |
WSTRINGZ [PTR] |
|
LRESULT |
signed 32-bit |
LONG |
NULL |
32-bit |
0 or %NULL |
PASCAL |
{calling convention} |
/STDCALL |
unsigned 64-bit |
QUAD (2) |
|
STDCALL |
{calling convention} |
SDECL/STDCALL |
UCHAR |
unsigned 8-bit |
BYTE |
unsigned 32-bit |
DWORD (3) |
|
UINT16 |
unsigned 16-bit |
WORD |
UINT32 |
unsigned 32-bit |
DWORD |
unsigned 64-bit |
QUAD (2) |
|
VOID |
SUB |
{no return value} |
(ANY) [PTR] (1) |
||
WINAPI |
{calling convention} |
SDECL/STDCALL |
WORD |
unsigned 16-bit |
WORD |
WPARAM |
signed 32-bit |
LONG |